<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Kitura Class Reference</title>
    <link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
    <link rel="stylesheet" type="text/css" href="../css/highlight.css" />
    <meta charset="utf-8">
    <script src="../js/jquery.min.js" defer></script>
    <script src="../js/jazzy.js" defer></script>
    
    <script src="../js/lunr.min.js" defer></script>
    <script src="../js/typeahead.jquery.js" defer></script>
    <script src="../js/jazzy.search.js" defer></script>
  </head>
  <body>

    <a name="//apple_ref/swift/Class/Kitura" class="dashAnchor"></a>

    <a title="Kitura Class Reference"></a>

    <header class="header">
      <p class="header-col header-col--primary">
        <a class="header-link" href="../index.html">
          Kitura Docs
        </a>
         (99% documented)
      </p>
    
      <p class="header-col--secondary">
        <form role="search" action="../search.json">
          <input type="text" placeholder="Search documentation" data-typeahead>
        </form>
      </p>
    
        <p class="header-col header-col--secondary">
          <a class="header-link" href="https://github.com/Kitura/Kitura/">
            <img class="header-icon" src="../img/gh.png"/>
            View on GitHub
          </a>
        </p>
    
    </header>

    <p class="breadcrumbs">
      <a class="breadcrumb" href="../index.html">Kitura Reference</a>
      <img class="carat" src="../img/carat.png" />
      Kitura Class Reference
    </p>

    <div class="content-wrapper">
      <nav class="navigation">
        <ul class="nav-groups">
          <li class="nav-group-name">
            <a class="nav-group-name-link" href="../Classes.html">Classes</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Classes/BodyParser.html">BodyParser</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Classes/BodyParserMultiValue.html">BodyParserMultiValue</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Classes/ContentType.html">ContentType</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Classes/Kitura.html">Kitura</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Classes/Router.html">Router</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Classes/RouterMiddlewareGenerator.html">RouterMiddlewareGenerator</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Classes/RouterRequest.html">RouterRequest</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Classes/RouterResponse.html">RouterResponse</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Classes/StaticFileServer.html">StaticFileServer</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Classes/StaticFileServer/CacheOptions.html">– CacheOptions</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Classes/StaticFileServer/Options.html">– Options</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a class="nav-group-name-link" href="../Enums.html">Enumerations</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Enums/JSONPError.html">JSONPError</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Enums/LinkParameter.html">LinkParameter</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Enums/ParsedBody.html">ParsedBody</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Enums/RouterMethod.html">RouterMethod</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a class="nav-group-name-link" href="../Extensions.html">Extensions</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Extensions/DecodingError.html">DecodingError</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a class="nav-group-name-link" href="../Protocols.html">Protocols</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Protocols/ResponseHeadersSetter.html">ResponseHeadersSetter</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Protocols/RouterMiddleware.html">RouterMiddleware</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Protocols/TypeSafeMiddleware.html">TypeSafeMiddleware</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a class="nav-group-name-link" href="../Structs.html">Structures</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Structs/AdditionalCookieAttribute.html">AdditionalCookieAttribute</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Structs/CodableHelpers.html">CodableHelpers</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Structs/HTTPVersion.html">HTTPVersion</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Structs/Headers.html">Headers</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Structs/MediaType.html">MediaType</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Structs/MediaType/TopLevelType.html">– TopLevelType</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Structs/Part.html">Part</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Structs/Part/HeaderType.html">– HeaderType</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Structs/SSLConfig.html">SSLConfig</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Structs/SwaggerDocument.html">SwaggerDocument</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a class="nav-group-name-link" href="../Typealiases.html">Type Aliases</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Typealiases.html#/s:6Kitura14HTTPStatusCodea">HTTPStatusCode</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Typealiases.html#/s:6Kitura16LifecycleHandlera">LifecycleHandler</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Typealiases.html#/s:6Kitura12RequestErrora">RequestError</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Typealiases.html#/s:6Kitura13RouterHandlera">RouterHandler</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Typealiases.html#/s:6Kitura22RouterParameterHandlera">RouterParameterHandler</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Typealiases.html#/s:6Kitura13ServerOptionsa">ServerOptions</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Typealiases.html#/s:6Kitura17WrittenDataFiltera">WrittenDataFilter</a>
              </li>
            </ul>
          </li>
        </ul>
      </nav>
      <article class="main-content">

        <section class="section">
          <div class="section-content top-matter">
            <h1>Kitura</h1>
              <div class="declaration">
                <div class="language">
                  
                  <pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">class</span> <span class="kt">Kitura</span></code></pre>

                </div>
              </div>
            <p>Facilities for creating, starting and stopping Kitura-based servers.</p>
<h3 id='usage-example' class='heading'>Usage Example:</h3>

<p>In this example, a <code><a href="../Classes/Router.html">Router</a></code> is created, and a single route registered that responds to an HTTP GET request on &ldquo;/&rdquo; with a plain text response.
An HTTP server is created on port 8080, and is started with the <code>Kitura.run()</code> function (note that this function does not return).
The route can then be accessed by visiting <code>http://localhost:8080</code>.</p>
<pre class="highlight swift"><code><span class="k">let</span> <span class="nv">router</span> <span class="o">=</span> <span class="kt">Router</span><span class="p">()</span>
<span class="n">router</span><span class="o">.</span><span class="nf">get</span><span class="p">(</span><span class="s">"/"</span><span class="p">)</span> <span class="p">{</span> <span class="n">request</span><span class="p">,</span> <span class="n">response</span><span class="p">,</span> <span class="n">next</span> <span class="k">in</span>
    <span class="n">response</span><span class="o">.</span><span class="nf">send</span><span class="p">(</span><span class="s">"Hello world"</span><span class="p">)</span>
    <span class="nf">next</span><span class="p">()</span>
<span class="p">}</span>
<span class="kt">Kitura</span><span class="o">.</span><span class="nf">addHTTPServer</span><span class="p">(</span><span class="nv">onPort</span><span class="p">:</span> <span class="mi">8080</span><span class="p">,</span> <span class="nv">onAddress</span><span class="p">:</span> <span class="s">"localhost"</span><span class="p">,</span> <span class="nv">with</span><span class="p">:</span> <span class="n">router</span><span class="p">)</span>
<span class="kt">Kitura</span><span class="o">.</span><span class="nf">run</span><span class="p">()</span>
</code></pre>

          </div>
        </section>

        <section class="section">
          <div class="section-content">
            <div class="task-group">
              <div class="task-name-container">
                <a name="/Create%20Server"></a>
                <a name="//apple_ref/swift/Section/Create Server" class="dashAnchor"></a>
                <div class="section-name-container">
                  <a class="section-name-link" href="#/Create%20Server"></a>
                  <h3 class="section-name"><p>Create Server</p>
</h3>
                </div>
              </div>
              <ul class="item-container">
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:6KituraAAC13addHTTPServer6onPort0D7Address4with0G3SSL9keepAlive05allowE5Reuse7options0A3Net0C0CSi_SSSgAK14ServerDelegate_pAA9SSLConfigVSgAK04KeepJ5StateOSbAK0O7OptionsVSgtFZ"></a>
                    <a name="//apple_ref/swift/Method/addHTTPServer(onPort:onAddress:with:withSSL:keepAlive:allowPortReuse:options:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:6KituraAAC13addHTTPServer6onPort0D7Address4with0G3SSL9keepAlive05allowE5Reuse7options0A3Net0C0CSi_SSSgAK14ServerDelegate_pAA9SSLConfigVSgAK04KeepJ5StateOSbAK0O7OptionsVSgtFZ">addHTTPServer(onPort:<wbr>onAddress:<wbr>with:<wbr>withSSL:<wbr>keepAlive:<wbr>allowPortReuse:<wbr>options:<wbr>)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Add an HTTPServer on a port with a delegate.</p>

<p>The server is only registered with the framework, it does not start listening
 on the port until <code>Kitura.run()</code> or <code><a href="../Classes/Kitura.html#/s:6KituraAAC5startyyFZ">Kitura.start()</a></code> are called.</p>
<h3 id='usage-example' class='heading'>Usage Example:</h3>
<pre class="highlight swift"><code> <span class="k">let</span> <span class="nv">router</span> <span class="o">=</span> <span class="kt">Router</span><span class="p">()</span>
 <span class="kt">Kitura</span><span class="o">.</span><span class="nf">addHTTPServer</span><span class="p">(</span><span class="nv">onPort</span><span class="p">:</span> <span class="mi">8080</span><span class="p">,</span> <span class="nv">onAddress</span><span class="p">:</span> <span class="s">"localhost"</span><span class="p">,</span> <span class="nv">with</span><span class="p">:</span> <span class="n">router</span><span class="p">)</span>
</code></pre>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight swift"><code><span class="kd">@discardableResult</span>
<span class="kd">public</span> <span class="kd">class</span> <span class="kd">func</span> <span class="nf">addHTTPServer</span><span class="p">(</span><span class="n">onPort</span> <span class="nv">port</span><span class="p">:</span> <span class="kt">Int</span><span class="p">,</span>
                                <span class="n">onAddress</span> <span class="nv">address</span><span class="p">:</span> <span class="kt">String</span><span class="p">?</span> <span class="o">=</span> <span class="kc">nil</span><span class="p">,</span>
                                <span class="n">with</span> <span class="nv">delegate</span><span class="p">:</span> <span class="kt">ServerDelegate</span><span class="p">,</span>
                                <span class="n">withSSL</span> <span class="nv">sslConfig</span><span class="p">:</span> <span class="kt"><a href="../Structs/SSLConfig.html">SSLConfig</a></span><span class="p">?</span><span class="o">=</span><span class="kc">nil</span><span class="p">,</span>
                                <span class="n">keepAlive</span> <span class="nv">keepAliveState</span><span class="p">:</span> <span class="kt">KeepAliveState</span> <span class="o">=</span> <span class="o">.</span><span class="n">unlimited</span><span class="p">,</span>
                                <span class="nv">allowPortReuse</span><span class="p">:</span> <span class="kt">Bool</span> <span class="o">=</span> <span class="kc">false</span><span class="p">,</span>
                                <span class="nv">options</span><span class="p">:</span> <span class="kt"><a href="../Typealiases.html#/s:6Kitura13ServerOptionsa">ServerOptions</a></span><span class="p">?</span> <span class="o">=</span> <span class="kc">nil</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">HTTPServer</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>onPort</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>The port to listen on.</p>
                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>onAddress</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>The address to listen on, for example &ldquo;localhost&rdquo;. The default is nil, which listens on
         all addresses.</p>
                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>with</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>The <code>ServerDelegate</code> to use.</p>
                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>withSSL</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>The <code>sslConfig</code> to use.</p>
                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>keepAlive</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>The maximum number of additional requests to permit per Keep-Alive connection. Defaults to <code>.unlimited</code>. If set to <code>.disabled</code>, Keep-Alive will not be permitted.</p>
                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>allowPortReuse</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>Determines whether the listener port may be shared with other Kitura instances (<code>SO_REUSEPORT</code>). Defaults to <code>false</code>. If the specified port is already in use by another listener that has not allowed sharing, the server will fail to start.</p>
                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>options</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>Allows customization of default policies for this server.</p>
                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                      <div>
                        <h4>Return Value</h4>
                        <p>The created <code>HTTPServer</code>.</p>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:6KituraAAC13addHTTPServer18onUnixDomainSocket4with0H3SSL9keepAlive7options0A3Net0C0CSS_AI14ServerDelegate_pAA9SSLConfigVSgAI04KeepK5StateOAI0N7OptionsVSgtFZ"></a>
                    <a name="//apple_ref/swift/Method/addHTTPServer(onUnixDomainSocket:with:withSSL:keepAlive:options:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:6KituraAAC13addHTTPServer18onUnixDomainSocket4with0H3SSL9keepAlive7options0A3Net0C0CSS_AI14ServerDelegate_pAA9SSLConfigVSgAI04KeepK5StateOAI0N7OptionsVSgtFZ">addHTTPServer(onUnixDomainSocket:<wbr>with:<wbr>withSSL:<wbr>keepAlive:<wbr>options:<wbr>)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Add an HTTPServer on a Unix domain socket path with a delegate.</p>

<p>The server is only registered with the framework, it does not start listening
 on the Unix socket until <code>Kitura.run()</code> or <code><a href="../Classes/Kitura.html#/s:6KituraAAC5startyyFZ">Kitura.start()</a></code> are called.</p>
<h3 id='usage-example' class='heading'>Usage Example:</h3>
<pre class="highlight swift"><code> <span class="k">let</span> <span class="nv">router</span> <span class="o">=</span> <span class="kt">Router</span><span class="p">()</span>
 <span class="kt">Kitura</span><span class="o">.</span><span class="nf">addHTTPServer</span><span class="p">(</span><span class="nv">onUnixDomainSocket</span><span class="p">:</span> <span class="s">"/tmp/mySocket"</span><span class="p">,</span> <span class="nv">with</span><span class="p">:</span> <span class="n">router</span><span class="p">)</span>
</code></pre>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight swift"><code><span class="kd">@discardableResult</span>
<span class="kd">public</span> <span class="kd">class</span> <span class="kd">func</span> <span class="nf">addHTTPServer</span><span class="p">(</span><span class="n">onUnixDomainSocket</span> <span class="nv">socketPath</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span>
                                <span class="n">with</span> <span class="nv">delegate</span><span class="p">:</span> <span class="kt">ServerDelegate</span><span class="p">,</span>
                                <span class="n">withSSL</span> <span class="nv">sslConfig</span><span class="p">:</span> <span class="kt"><a href="../Structs/SSLConfig.html">SSLConfig</a></span><span class="p">?</span><span class="o">=</span><span class="kc">nil</span><span class="p">,</span>
                                <span class="n">keepAlive</span> <span class="nv">keepAliveState</span><span class="p">:</span> <span class="kt">KeepAliveState</span> <span class="o">=</span> <span class="o">.</span><span class="n">unlimited</span><span class="p">,</span>
                                <span class="nv">options</span><span class="p">:</span> <span class="kt"><a href="../Typealiases.html#/s:6Kitura13ServerOptionsa">ServerOptions</a></span><span class="p">?</span> <span class="o">=</span> <span class="kc">nil</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">HTTPServer</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>onUnixDomainSocket</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>The path of the Unix domain socket to listen on.</p>
                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>with</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>The <code>ServerDelegate</code> to use.</p>
                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>withSSL</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>The <code>sslConfig</code> to use.</p>
                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>keepAlive</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>The maximum number of additional requests to permit per Keep-Alive connection. Defaults to <code>.unlimited</code>. If set to <code>.disabled</code>, Keep-Alive will not be permitted.</p>
                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                      <div>
                        <h4>Return Value</h4>
                        <p>The created <code>HTTPServer</code>.</p>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:6KituraAAC16addFastCGIServer6onPort0E7Address4with05allowF5Reuse0A3Net0cD0CSi_SSSgAH14ServerDelegate_pSbtFZ"></a>
                    <a name="//apple_ref/swift/Method/addFastCGIServer(onPort:onAddress:with:allowPortReuse:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:6KituraAAC16addFastCGIServer6onPort0E7Address4with05allowF5Reuse0A3Net0cD0CSi_SSSgAH14ServerDelegate_pSbtFZ">addFastCGIServer(onPort:<wbr>onAddress:<wbr>with:<wbr>allowPortReuse:<wbr>)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Add a FastCGIServer on a port with a delegate.</p>

<p>The server is only registered with the framework, it does not start listening
 on the port until <code>Kitura.run()</code> or <code><a href="../Classes/Kitura.html#/s:6KituraAAC5startyyFZ">Kitura.start()</a></code> are called.</p>
<h3 id='usage-example' class='heading'>Usage Example:</h3>
<pre class="highlight swift"><code> <span class="k">let</span> <span class="nv">router</span> <span class="o">=</span> <span class="kt">Router</span><span class="p">()</span>
 <span class="kt">Kitura</span><span class="o">.</span><span class="nf">addFastCGIServer</span><span class="p">(</span><span class="nv">onPort</span><span class="p">:</span> <span class="mi">8080</span><span class="p">,</span> <span class="nv">onAddress</span><span class="p">:</span> <span class="s">"localhost"</span><span class="p">,</span> <span class="nv">with</span><span class="p">:</span> <span class="n">router</span><span class="p">)</span>
</code></pre>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight swift"><code><span class="kd">@discardableResult</span>
<span class="kd">public</span> <span class="kd">class</span> <span class="kd">func</span> <span class="nf">addFastCGIServer</span><span class="p">(</span><span class="n">onPort</span> <span class="nv">port</span><span class="p">:</span> <span class="kt">Int</span><span class="p">,</span>
                                   <span class="n">onAddress</span> <span class="nv">address</span><span class="p">:</span> <span class="kt">String</span><span class="p">?</span> <span class="o">=</span> <span class="kc">nil</span><span class="p">,</span>
                                   <span class="n">with</span> <span class="nv">delegate</span><span class="p">:</span> <span class="kt">ServerDelegate</span><span class="p">,</span>
                                   <span class="nv">allowPortReuse</span><span class="p">:</span> <span class="kt">Bool</span> <span class="o">=</span> <span class="kc">false</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">FastCGIServer</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>onPort</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>The port to listen on.</p>
                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>onAddress</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>The address to listen on, for example &ldquo;localhost&rdquo;. The default is nil, which listens on
         all addresses.</p>
                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>with</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>The <code>ServerDelegate</code> to use.</p>
                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>allowPortReuse</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>Determines whether the listener port may be shared with other Kitura instances (<code>SO_REUSEPORT</code>). Defaults to <code>false</code>. If the specified port is already in use by another listener that has not allowed sharing, the server will fail to start.</p>
                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                      <div>
                        <h4>Return Value</h4>
                        <p>The created <code>FastCGIServer</code>.</p>
                      </div>
                    </section>
                  </div>
                </li>
              </ul>
            </div>
            <div class="task-group">
              <div class="task-name-container">
                <a name="/Start%20Servers"></a>
                <a name="//apple_ref/swift/Section/Start Servers" class="dashAnchor"></a>
                <div class="section-name-container">
                  <a class="section-name-link" href="#/Start%20Servers"></a>
                  <h3 class="section-name"><p>Start Servers</p>
</h3>
                </div>
              </div>
              <ul class="item-container">
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:6KituraAAC3run13exitOnFailureySb_tFZ"></a>
                    <a name="//apple_ref/swift/Method/run(exitOnFailure:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:6KituraAAC3run13exitOnFailureySb_tFZ">run(exitOnFailure:<wbr>)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Start the Kitura framework.
 By default, the Kitura framework process will exit if one or more of the servers fails to start. To prevent the Kitura framework process from exiting with set the <code>exitOnFailure</code> parameter to false.</p>
<h3 id='usage-example' class='heading'>Usage Example:</h3>

<p>Make all registered servers start listening on their port.</p>
<pre class="highlight swift"><code> <span class="k">let</span> <span class="nv">router</span> <span class="o">=</span> <span class="kt">Router</span><span class="p">()</span>
 <span class="kt">Kitura</span><span class="o">.</span><span class="nf">addHTTPServer</span><span class="p">(</span><span class="nv">onPort</span><span class="p">:</span> <span class="mi">8080</span><span class="p">,</span> <span class="nv">onAddress</span><span class="p">:</span> <span class="s">"localhost"</span><span class="p">,</span> <span class="nv">with</span><span class="p">:</span> <span class="n">router</span><span class="p">)</span>
 <span class="kt">Kitura</span><span class="o">.</span><span class="nf">run</span><span class="p">()</span>
</code></pre>

<p>Make all registered servers start listening on their port and exit if any fail to start.</p>
<pre class="highlight swift"><code> <span class="k">let</span> <span class="nv">router</span> <span class="o">=</span> <span class="kt">Router</span><span class="p">()</span>
 <span class="kt">Kitura</span><span class="o">.</span><span class="nf">addHTTPServer</span><span class="p">(</span><span class="nv">onPort</span><span class="p">:</span> <span class="mi">8080</span><span class="p">,</span> <span class="nv">with</span><span class="p">:</span> <span class="n">router</span><span class="p">)</span>
 <span class="kt">Kitura</span><span class="o">.</span><span class="nf">run</span><span class="p">(</span><span class="nv">exitOnFailure</span><span class="p">:</span> <span class="kc">false</span><span class="p">)</span>
</code></pre>
<div class="aside aside-note">
    <p class="aside-title">Note</p>
    This function never returns - it should be the last call in your <code>main.swift</code> file.

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">class</span> <span class="kd">func</span> <span class="nf">run</span><span class="p">(</span><span class="nv">exitOnFailure</span><span class="p">:</span> <span class="kt">Bool</span> <span class="o">=</span> <span class="kc">true</span><span class="p">)</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>exitOnFailure</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>Determines whether the Kitura process can return a non-zero exit code should any of the servers fail to start. Defaults to true, indicating it will exit if any of the servers fail to start.</p>
                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:6KituraAAC5startyyFZ"></a>
                    <a name="//apple_ref/swift/Method/start()" class="dashAnchor"></a>
                    <a class="token" href="#/s:6KituraAAC5startyyFZ">start()</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Start all registered servers and return.</p>
<h3 id='usage-example' class='heading'>Usage Example:</h3>

<p>Make all registered servers start listening on their port.</p>
<pre class="highlight swift"><code> <span class="k">let</span> <span class="nv">router</span> <span class="o">=</span> <span class="kt">Router</span><span class="p">()</span>
 <span class="kt">Kitura</span><span class="o">.</span><span class="nf">addHTTPServer</span><span class="p">(</span><span class="nv">onPort</span><span class="p">:</span> <span class="mi">8080</span><span class="p">,</span> <span class="nv">onAddress</span><span class="p">:</span> <span class="s">"localhost"</span><span class="p">,</span> <span class="nv">with</span><span class="p">:</span> <span class="n">router</span><span class="p">)</span>
 <span class="kt">Kitura</span><span class="o">.</span><span class="nf">start</span><span class="p">()</span>
</code></pre>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">class</span> <span class="kd">func</span> <span class="nf">start</span><span class="p">()</span></code></pre>

                        </div>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:6KituraAAC4waityyFZ"></a>
                    <a name="//apple_ref/swift/Method/wait()" class="dashAnchor"></a>
                    <a class="token" href="#/s:6KituraAAC4waityyFZ">wait()</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Wait on all registered servers.</p>
<h3 id='usage-example' class='heading'>Usage Example:</h3>
<pre class="highlight swift"><code> <span class="k">let</span> <span class="nv">failures</span> <span class="o">=</span> <span class="kt">Kitura</span><span class="o">.</span><span class="nf">startWithStatus</span><span class="p">()</span>
 <span class="k">if</span> <span class="n">failures</span> <span class="o">==</span> <span class="mi">0</span> <span class="p">{</span>
   <span class="kt">Kitura</span><span class="o">.</span><span class="nf">wait</span><span class="p">()</span>
 <span class="k">else</span> <span class="p">{</span>
   <span class="c1">// handle failures</span>
 <span class="p">}</span>
</code></pre>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">class</span> <span class="kd">func</span> <span class="nf">wait</span><span class="p">()</span></code></pre>

                        </div>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:6KituraAAC15startWithStatusSiyFZ"></a>
                    <a name="//apple_ref/swift/Method/startWithStatus()" class="dashAnchor"></a>
                    <a class="token" href="#/s:6KituraAAC15startWithStatusSiyFZ">startWithStatus()</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Start all registered servers and return the number of servers that failed to start.</p>
<h3 id='usage-example' class='heading'>Usage Example:</h3>

<p>Make all registered servers start listening on their port.</p>
<pre class="highlight swift"><code> <span class="k">let</span> <span class="nv">router</span> <span class="o">=</span> <span class="kt">Router</span><span class="p">()</span>
 <span class="kt">Kitura</span><span class="o">.</span><span class="nf">addHTTPServer</span><span class="p">(</span><span class="nv">onPort</span><span class="p">:</span> <span class="mi">8080</span><span class="p">,</span> <span class="nv">onAddress</span><span class="p">:</span> <span class="s">"localhost"</span><span class="p">,</span> <span class="nv">with</span><span class="p">:</span> <span class="n">router</span><span class="p">)</span>
 <span class="kt">Kitura</span><span class="o">.</span><span class="nf">startWithStatus</span><span class="p">()</span> <span class="c1">// Returns the number of failed server starts.</span>
</code></pre>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">class</span> <span class="kd">func</span> <span class="nf">startWithStatus</span><span class="p">()</span> <span class="o">-&gt;</span> <span class="kt">Int</span></code></pre>

                        </div>
                      </div>
                    </section>
                  </div>
                </li>
              </ul>
            </div>
            <div class="task-group">
              <div class="task-name-container">
                <a name="/Stop%20Servers"></a>
                <a name="//apple_ref/swift/Section/Stop Servers" class="dashAnchor"></a>
                <div class="section-name-container">
                  <a class="section-name-link" href="#/Stop%20Servers"></a>
                  <h3 class="section-name"><p>Stop Servers</p>
</h3>
                </div>
              </div>
              <ul class="item-container">
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:6KituraAAC4stop10unregisterySb_tFZ"></a>
                    <a name="//apple_ref/swift/Method/stop(unregister:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:6KituraAAC4stop10unregisterySb_tFZ">stop(unregister:<wbr>)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Stop all registered servers.</p>
<h3 id='usage-example' class='heading'>Usage Example:</h3>

<p>Make all registered servers stop listening on their port.</p>
<pre class="highlight swift"><code> <span class="k">let</span> <span class="nv">router</span> <span class="o">=</span> <span class="kt">Router</span><span class="p">()</span>
 <span class="kt">Kitura</span><span class="o">.</span><span class="nf">addHTTPServer</span><span class="p">(</span><span class="nv">onPort</span><span class="p">:</span> <span class="mi">8080</span><span class="p">,</span> <span class="nv">with</span><span class="p">:</span> <span class="n">router</span><span class="p">,</span> <span class="nv">address</span><span class="p">:</span> <span class="s">"localhost"</span><span class="p">)</span>
 <span class="kt">Kitura</span><span class="o">.</span><span class="nf">start</span><span class="p">()</span>
 <span class="kt">Kitura</span><span class="o">.</span><span class="nf">stop</span><span class="p">()</span>
</code></pre>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">class</span> <span class="kd">func</span> <span class="nf">stop</span><span class="p">(</span><span class="nv">unregister</span><span class="p">:</span> <span class="kt">Bool</span> <span class="o">=</span> <span class="kc">true</span><span class="p">)</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>unregister</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>If servers should be unregistered after they are stopped (default true).</p>
                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:6KituraAAC5logToyy7Logging6LoggerVFZ"></a>
                    <a name="//apple_ref/swift/Method/logTo(_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:6KituraAAC5logToyy7Logging6LoggerVFZ">logTo(_:<wbr>)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Instructs Kitura and LoggerAPI to log messages to a Swift Logger that you provide.
Usage example:</p>
<pre class="highlight swift"><code><span class="kd">import</span> <span class="kt">Kitura</span>
<span class="kd">import</span> <span class="kt">Logging</span>

<span class="k">var</span> <span class="nv">logger</span> <span class="o">=</span> <span class="kt">Logger</span><span class="p">(</span><span class="nv">label</span><span class="p">:</span> <span class="s">"MyLogger"</span><span class="p">)</span>
<span class="n">logger</span><span class="o">.</span><span class="n">logLevel</span> <span class="o">=</span> <span class="o">.</span><span class="n">debug</span>
<span class="kt">Kitura</span><span class="o">.</span><span class="nf">logTo</span><span class="p">(</span><span class="n">logger</span><span class="p">)</span>
</code></pre>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">static</span> <span class="kd">func</span> <span class="nf">logTo</span><span class="p">(</span><span class="n">_</span> <span class="nv">logger</span><span class="p">:</span> <span class="kt">Logging</span><span class="o">.</span><span class="kt">Logger</span><span class="p">)</span></code></pre>

                        </div>
                      </div>
                    </section>
                  </div>
                </li>
              </ul>
            </div>
          </div>
        </section>

      </article>
    </div>
    <section class="footer">
      <p>&copy; 2021 <a class="link" href="" target="_blank" rel="external">IBM &amp; Kitura project authors</a>. All rights reserved. (Last updated: 2021-01-25)</p>
      <p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.13.6</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
    </section>
  </body>
</div>
</html>
